<!--<div class="uimssVarieties" style="height: 100%;width:100%;overflow:auto;position: relative;">-->
    <!--<div class="button-group-head" style="">-->
        <!--&lt;!&ndash;<span class="hrp-btn hrp-btn-add" id="openDialog"><i class="fa fa-plus" style="padding-right: 4px;"></i>添加</span>&ndash;&gt;-->
        <!--&lt;!&ndash;<span  class="hrp-btn hrp-btn-refresh"><i class="fa fa-refresh" style="padding-right: 4px;"></i>刷新</span>&ndash;&gt;-->



        <!--<span style="height:40px;line-height: 34px;float: left;padding-right: 5px;font-size:14px;">开始日期:</span>-->
        <!--<span style="height: 40px;float: left;padding-right: 20px;">-->
            <!--<input id="sendTimeKsrq" name="dept">-->
        <!--</span>-->
        <!--<span style="height:40px;line-height: 34px;float: left;padding-right: 5px;font-size:14px;">结束日期:</span>-->
        <!--<span style="height: 40px;float: left;padding-right: 20px;">-->
            <!--<input id="sendTimeJsrq" name="dept">-->
        <!--</span>-->

        <!--<span class="hrp-btn hrp-btn-add" id="btn-query"><i class="fa fa-plus" style="padding-right: 4px;"></i>查询</span>-->

        <!--<span class="hrp-btn hrp-btn-add" id="excelExport" style="float: right;"><i class="fa fa-file-excel-o" style="padding-right: 4px;"></i>导出excel</span>-->
    <!--</div>-->

    <!--<div>-->
        <!--<table id="dg" class="easyui-datagrid" style="width:100%;">-->
            <!--&lt;!&ndash;<thead>&ndash;&gt;-->
            <!--&lt;!&ndash;<tr>&ndash;&gt;-->
            <!--&lt;!&ndash;<th  width="15%">Item ID(15%)</th>&ndash;&gt;-->
            <!--&lt;!&ndash;<th  width="15%">Product(15%)</th>&ndash;&gt;-->
            <!--&lt;!&ndash;<th  width="15%">List Price(15%)</th>&ndash;&gt;-->
            <!--&lt;!&ndash;<th  width="15%">List Price(15%)</th>&ndash;&gt;-->
            <!--&lt;!&ndash;<th width="15%">List Price(15%)</th>&ndash;&gt;-->
            <!--&lt;!&ndash;</tr>&ndash;&gt;-->
            <!--&lt;!&ndash;</thead>&ndash;&gt;-->
        <!--</table>-->
    <!--</div>-->

<!--</div>-->



<div class="uimssVarieties" style="height: 100%;width:100%;overflow:auto;position: relative;padding-top: 42px;background-color: #fff;">
    <div class="button-group-head" style="position: absolute;left: 0;top: 0;width: 100%;border-bottom: none;">

        <span style="height:40px;line-height: 34px;float: left;padding-right: 5px;font-size:14px;">开始日期:</span>
        <span style="height: 40px;float: left;padding-right: 20px;">
            <input id="sendTimeKsrq" name="dept">
        </span>
        <span style="height:40px;line-height: 34px;float: left;padding-right: 5px;font-size:14px;">结束日期:</span>
        <span style="height: 40px;float: left;padding-right: 20px;">
            <input id="sendTimeJsrq" name="dept">
        </span>

        <span class="hrp-btn hrp-btn-add" id="btn-query"><i class="fa fa-plus" style="padding-right: 4px;"></i>查询</span>

        <span class="hrp-btn hrp-btn-add" id="excelExport" style="float: right;"><i class="fa fa-file-excel-o" style="padding-right: 4px;"></i>导出excel</span>
    </div>
    <!--<div class="jxkhzbk-toolbar" style="position: absolute;left: 0;top: 42px;width: 100%;">-->
    <!--<span style="padding-top: 4px;height: 40px;float: right;padding-right: 20px;">-->
    <!--<input id="receiverId" name="dept">-->
    <!--</span>-->
    <!--<span style="height:40px;line-height: 40px;float: right;padding-right: 5px;font-size:14px;">收货方:</span>-->

    <!--<span style="padding-top: 4px;height: 40px;float: right;padding-right: 20px;">-->
    <!--<input id="supplierId" name="dept">-->
    <!--</span>-->
    <!--<span style="height:40px;line-height: 40px;float: right;padding-right: 5px;font-size:14px;">发货方:</span>-->




    <!--<span style="padding-top: 4px;height: 40px;float: right;padding-right: 20px;">-->
    <!--<input id="varietiesId" name="dept">-->
    <!--</span>-->
    <!--<span style="height:40px;line-height: 40px;float: right;padding-right: 5px;font-size:14px;">种类:</span>-->
    <!--</div>-->
    <div style="height: 100%;width: 100%;border:1px solid #cccccc;position: relative;">
        <div class="uimssVarieties-content-left" style="position: absolute;left: 0;top:0;height: 100%;width: 450px;">
            <!--<div style="position: absolute;left: 0;top:0;width:150px;height:100%;overflow: auto;padding-top: 30px;">-->
                <!--<div style="position: absolute;left: 0;top:0;width: 100%;height: 30px;">-->
                    <!--<input class="search-input"  data-action="varietiesIdSearch"   style="height: 30px;border-bottom:1px solid #ccc;width:100%;margin: 0;padding: 0;padding: 2px;line-height: 30px;" placeholder="搜索分类"/>-->
                <!--</div>-->
                <!--<div style="height: 100%;width: 100%;overflow: auto;">-->
                    <!--<ul id="varietiesIdTree"></ul>-->
                <!--</div>-->
            <!--</div>-->
            <!--<div style="position: absolute;left: 150px;top:0;width:150px;height:100%;;border-left:1px solid #ccc;overflow: auto;padding-top: 30px;">-->
                <!--<div style="position: absolute;left: 0;top:0;width: 100%;height: 30px;">-->
                    <!--<input class="search-input"   data-action="supplierIddSearch"  style="height: 30px;border-bottom:1px solid #ccc;width:100%;margin: 0;padding: 0;padding: 2px;line-height: 30px;" placeholder="搜索发货地"/>-->
                <!--</div>-->
                <!--<div style="height: 100%;width: 100%;overflow: auto;">-->
                    <!--<ul id="supplierIdTree"></ul>-->
                <!--</div>-->
            <!--</div>-->
            <div style="position: absolute;left: 0;top:0;width:150px;height:100%;border-left:1px solid #ccc;overflow: auto;padding-top: 30px;">
                <div style="position: absolute;left: 0;top:0;width: 100%;height: 30px;">
                    <input class="search-input" data-action="receiverIdSearch"   style="height: 30px;border-bottom:1px solid #ccc;width:100%;margin: 0;padding: 0;padding: 2px;line-height: 30px;" placeholder="搜索收货地"/>
                </div>
                <div style="height: 100%;width: 100%;overflow: auto;">
                    <ul id="receiverIdTree"></ul>
                </div>
            </div>
        </div>
        <div class="uimssVarieties-content-main" style="height: 100%;margin-left: 150px;border-left:1px solid #ccc;overflow: auto;">
            <table id="dg" class="easyui-datagrid" style="width:100%;">
                <!--<thead>-->
                <!--<tr>-->
                <!--<th  width="15%">Item ID(15%)</th>-->
                <!--<th  width="15%">Product(15%)</th>-->
                <!--<th  width="15%">List Price(15%)</th>-->
                <!--<th  width="15%">List Price(15%)</th>-->
                <!--<th width="15%">List Price(15%)</th>-->
                <!--</tr>-->
                <!--</thead>-->
            </table>
        </div>
    </div>


</div>







<script type="text/javascript">

    var dHeight = $(".uimssVarieties").height()-42;

    var UserIndexPage={
        tableName:"UIMSS_SUPPLIERINFO",
        editPriceFlag:false,
        init:function () {
            this.initEvnets();
            this.initSendTimeKsrqCombox();
            this.initSendTimeJsrqCombox();
            //this.initGrid();
            this.initReceiverTree();
        },
        initReceiverTree:function (searchValue) {
            $('#receiverIdTree').tree({
                url:'common/getUimssReceiverTree',
                checkbox:true,
                queryParams:{
                    "searchValue":searchValue
                }
            });
        },
        initVarietiesComBox:function (id) {
            $('#varietiesId').combobox({
                url:"common/getUimssVarietiesDropList",
                queryParams: {
                    "id": id
                },
                valueField:'id',
                textField:'text',
                width:200,
                panelHeight:200,
                onSelect:function (record) {
                    if(UserIndexPage.editPriceFlag==false){
                        $("#price").val(record.value);
                    }
                },
                onLoadSuccess:function () {

                }
            });
        },
        initSupplierComBox:function (id) {
            $('#supplierId').combobox({
                url:"common/getUimssSupplierDropList",
                queryParams: {
                    "id": id
                },
                valueField:'id',
                textField:'text',
                width:200,
                panelHeight:200,
                onSelect:function (record) {

                },
                onLoadSuccess:function () {

                }
            });
        },
        initReceiverCombox:function (id) {
            $('#receiverId').combobox({
                url:"common/getUimssReceiverDropList",
                queryParams: {
                    "id": id
                },
                valueField:'id',
                textField:'text',
                width:200,
                panelHeight:200,
                onSelect:function (record) {

                },
                onLoadSuccess:function () {

                }
            });
        },
        initCombox:function () {

            var that= this;
            $('#sendTime').datebox({
                formatter : function(date){

                    //var date = new Date();
                    var year = date.getFullYear();
                    var month = date.getMonth() + 1;
                    var day = date.getDate();
                    var hour = date.getHours();
                    month = month < 10 ? '0' + month : month;
                    day = day < 10 ? '0' + day : day;
                    hour = hour < 10 ? '0' + hour : hour;
                    return year + "-" + month + "-" + day ;
                },
                parser:function (s) {
                    s = s.replace(/\s+/,' ');//解决格式字符串中多个空格拼接在Firefox中无法兼容的问题
                    var t = Date.parse(s);
                    if (!isNaN(t)){
                        return new Date(t);
                    } else {
                        return new Date(s + ":00");
                    }
                },
                onSelect:function (date) {

                }
            });

            $('#sendTime').datebox('setValue', that.formatterDate(new Date()));
        },
        initEvnets:function () {
            var that = this;
            $(window).resize(function () {
                $('#dg').datagrid("resize")
            })

            $("#btn-query").on("click",function () {
                that.initGrid();
            })

            $("#excelExport").on("click",function () {

                var startTime = $('#sendTimeKsrq').datebox('getValue');
                var endTime = $('#sendTimeJsrq').datebox('getValue');


                var receiverIdArr = $('#receiverIdTree').tree('getChecked');
                var receiverIdStr='';
                for(var i=0;i<receiverIdArr.length;i++){
                    if(i<receiverIdArr.length-1){
                        receiverIdStr+=receiverIdArr[i].id+',';
                    }else{
                        receiverIdStr+=receiverIdArr[i].id;
                    }
                }

                window.location.href="export/exportAccountsReceivable?startTime="+startTime+"&endTime="+endTime+"&receiverIdStr="+receiverIdStr+"&rnd="+Math.random();
            })

            $(".uimssVarieties").on("keyup",".search-input",function () {
                var newValue = $(this).val();
                var oldValue=$(this).data("oldValue");
                if(!oldValue){
                    oldValue="";
                }
                if( $(this).attr("data-action")=="varietiesIdSearch"){
                    if($.trim(newValue)!=$.trim(oldValue)){
                        // console.log("varietiesIdSearch");
                        that.initVarietiesTree(newValue);
                    }
                }else if($(this).attr("data-action")=="supplierIddSearch"){
                    if($.trim(newValue)!=$.trim(oldValue)){
                        //console.log("supplierIddSearch");
                        that.initSupplierTree(newValue);
                    }
                }else if( $(this).attr("data-action")=="receiverIdSearch"){
                    if($.trim(newValue)!=$.trim(oldValue)){
                        //console.log("receiverIdSearch");
                        that.initReceiverTree(newValue);
                    }
                }

                $(this).data("oldValue",newValue);

            })

        },
        initSendTimeJsrqCombox:function () {

            var that= this;
            $('#sendTimeKsrq').datebox({
                formatter : function(date){

                    //var date = new Date();
                    var year = date.getFullYear();
                    var month = date.getMonth() + 1;
                    var day = date.getDate();
                    var hour = date.getHours();
                    month = month < 10 ? '0' + month : month;
                    day = day < 10 ? '0' + day : day;
                    hour = hour < 10 ? '0' + hour : hour;
                    return year + "-" + month + "-" + day ;
                },
                parser:function (s) {
                    s = s.replace(/\s+/,' ');//解决格式字符串中多个空格拼接在Firefox中无法兼容的问题
                    var t = Date.parse(s);
                    if (!isNaN(t)){
                        return new Date(t);
                    } else {
                        return new Date(s + ":00");
                    }
                },
                onSelect:function (date) {

                }
            });
            $('#sendTimeKsrq').datebox('setValue', that.formatterDate(that.setDateMonth(new Date())));
        },
        initSendTimeKsrqCombox:function () {

            var that= this;
            $('#sendTimeJsrq').datebox({
                formatter : function(date){
                    //var date = new Date();
                    var year = date.getFullYear();
                    var month = date.getMonth() + 1;
                    var day = date.getDate();
                    var hour = date.getHours();
                    month = month < 10 ? '0' + month : month;
                    day = day < 10 ? '0' + day : day;
                    hour = hour < 10 ? '0' + hour : hour;
                    return year + "-" + month + "-" + day ;
                },
                parser:function (s) {
                    s = s.replace(/\s+/,' ');//解决格式字符串中多个空格拼接在Firefox中无法兼容的问题
                    var t = Date.parse(s);
                    if (!isNaN(t)){
                        return new Date(t);
                    } else {
                        return new Date(s + ":00");
                    }
                },
                onSelect:function (date) {

                }
            });
            $('#sendTimeJsrq').datebox('setValue', that.formatterDate(new Date()));
        },
        //得到当前日期
        formatterDate : function(date,type) {
            var day = date.getDate() > 9 ? date.getDate() : "0" + date.getDate();
            var month = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : "0" + (date.getMonth() + 1);
            return date.getFullYear() + '-' + month + '-' + day;

        },
        setDateMonth:function (date) {
            var d = new Date(date);
            var month = d.getMonth();
            if (11 === month) {
                var year = d.getFullYear();
                d.setMonth(0);
                d.setFullYear(year + 1);
            } else {
                d.setMonth(month - 1);
            }
            return d;
        },
        //验证字符串是否是数字
        checkNumber:function(theObj) {
            var reg = /^[0-9]+.?[0-9]*$/;
            if (reg.test(theObj)) {
                return true;
            }
            return false;
        },
        initGrid:function () {


            var startTime = $('#sendTimeKsrq').datebox('getValue');
            var endTime = $('#sendTimeJsrq').datebox('getValue');



            var receiverIdArr = $('#receiverIdTree').tree('getChecked');
            var receiverIdStr='';
            for(var i=0;i<receiverIdArr.length;i++){
                if(i<receiverIdArr.length-1){
                    receiverIdStr+=receiverIdArr[i].id+',';
                }else{
                    receiverIdStr+=receiverIdArr[i].id;
                }
            }


            $('#dg').datagrid({
                url: "accountsReceivable/getAccountsReceivableByPage",
                queryParams: {
                    "startTime": startTime,
                    "endTime":endTime,
                    "receiverIdStr":receiverIdStr
                },
               // pagination: true,
                singleSelect: true,
                height:dHeight-4,   //表格高度，可指定高度，可自动
               // pageNumber: 1,
               // pageSize: 15,
               // pageList: [15, 30],
                fitColumns:true,
                loadMsg: "正在加载数据",
                nowrap: false,
                striped: true,  //奇偶行是否使用不同的颜色
                frozenColumns:[
                    [
                    {
                        field: 'receiverName', title: '收货方', width: "10%", align: 'center',
                        styler: function (value, row, index) {
                            return 'color:red;';
                        }
                    },
                    {field:'supplierName',title:'发货方',width:"10%"},
                    {field:'varietiesName',title:'种类',width:"10%"}
                ]
                ],
                columns:[[

                        //{field:'startTime',title:'开始日期',width:"10%"},
                        {field:'timeSlot',title:'日期区间',width:"10%"},
                        {field:'price',title:'单价',width:"5%"},
                        {field:'jz',title:'材料(净重)',width:"10%"},
                        {field:'alreadySettleAccountsJz',title:'材料(已开票净重)',width:"10%"},
                        {field:'withoutSettleAccountsJz',title:'材料(未开票净重)',width:"10%"},
                        {field:'je',title:'应收金额',width:"10%"},
                        {field:'alreadySettleAccountsMoney',title:'已开票金额',width:"10%"},
                        {field:'withoutSettleAccountsMoney',title:'未开票金额',width:"10%"},
                        {field:'shouldMoney',title:'应收总金额',width:"10%"},
                        {field:'alreadySettleAccountsMoneyAll',title:'已开票总金额',width:"10%"},
                        {field:'withoutSettleAccountsMoneyAll',title:'未开票总金额',width:"10%"},
                        //{field:'je',title:'已收账款',width:"10%"},
                        {field:'acceptedMoney',title:'乙方打款总金额',width:"10%"},
                        {field:'arrears',title:'还欠款',width:"10%"},
                        {
                            field: 'edit', title: '操作', width: "5%",
                            formatter: function (value, row, index) {
                                return "<a class='btn-edit' href='#'   >结账</a>"
                            }
                        }
                    ]
                ],
                onLoadSuccess:function(){
                    $.post("accountsReceivable/datagridMergeCells", {"startTime": startTime,"endTime":endTime,"receiverIdStr":receiverIdStr}, function (result) {

                            var merges =result;
                            for(var i=0; i<merges.length; i++){
                                $('#dg').datagrid('mergeCells',{
                                    index:merges[i].index,
                                    field:'receiverName',
                                    rowspan:merges[i].rowspan
                                })

                                $('#dg').datagrid('mergeCells',{
                                    index:merges[i].index,
                                    field:'shouldMoney',
                                    rowspan:merges[i].rowspan
                                })

                                $('#dg').datagrid('mergeCells',{
                                    index:merges[i].index,
                                    field:'acceptedMoney',
                                    rowspan:merges[i].rowspan
                                })

                                $('#dg').datagrid('mergeCells',{
                                    index:merges[i].index,
                                    field:'arrears',
                                    rowspan:merges[i].rowspan
                                })
                                $('#dg').datagrid('mergeCells',{
                                    index:merges[i].index,
                                    field:'edit',
                                    rowspan:merges[i].rowspan
                                })
                                $('#dg').datagrid('mergeCells',{
                                    index:merges[i].index,
                                    field:'alreadySettleAccountsMoneyAll',
                                    rowspan:merges[i].rowspan
                                })
                                $('#dg').datagrid('mergeCells',{
                                    index:merges[i].index,
                                    field:'withoutSettleAccountsMoneyAll',
                                    rowspan:merges[i].rowspan
                                })

                            }
                    })

                }
            });

        }
    }
    $(function () {
        UserIndexPage.init();
    })
</script>